<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<input type="file" onchange="fen.imagePreview(this,'previewImg')"/>
<img id="previewImg">
<script>
    (function(){
        window.fen = window.fen || {};
        //图片上传预览    IE是用了滤镜。
        fen.imagePreview = function(file,previewImgId,fn){
            var img = document.getElementById(previewImgId);
            if (file.files && file.files[0])
            {
                var reader = new FileReader();
                reader.onload = function(evt){img.src = evt.target.result;}
                reader.readAsDataURL(file.files[0]);
            }
            else //兼容IE
            {
                var selection = document.selection || document.getSelections;
                file.select();
                var src = selection.createRange().text;
                img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
            }
            if(fn){fn.apply(file);}
        }
    })();
</script>
</body>
</html>